package com.example.demo.controller;

import com.example.demo.model.entity.Agree;
import com.example.demo.model.entity.Article;
import com.example.demo.service.AgreeService;
import com.example.demo.service.ArticleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;



@RestController
@RequestMapping("/api/agree")
public class AgreeController {
    @Resource
    private AgreeService agreeService;
    @Resource
    private ArticleService articleService;


    @PostMapping("")
    public Agree agree(@RequestBody Agree agree) {
        articleService.agree(agree.getId());
        return agreeService.agree(agree);
    }


    @PostMapping("/del")
    public void disAgree(@RequestBody Agree agree){
        articleService.disAgree(agree.getId());
        agreeService.disagree(agree);
    }

    @PostMapping("/findbyid")
    public Boolean findById(@RequestBody Agree agree){

        return agreeService.findById(agree);
    }

}
